home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / speedbal.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  11KB  |  361 lines

  1. /***************************************************************************
  2.  
  3. Speed Ball map
  4.  
  5. driver by Joseba Epalza
  6.  
  7. Z80 MAIN CPU
  8. 0000-7fff ROM 1 32k
  9. 8000-dbff ROM 2 data
  10. dc00-dfff for both CPU&SOUND (Shared)
  11. e000-e1ff Video RAM background tiles 16*16 (2 bytes: 1 for tile char + 1 for color)
  12. e800-efff Video RAM characters 32*32 (2 bytes: 1 for char and 1 for color)
  13. f000-feff RAM
  14. ff00-ffff Sprites (64 total: four bytes to one)
  15.  
  16. in:
  17. 00    DSW ONE
  18. 10    DSW TWO
  19. 20    IN1  JOY 1 STATUS & COIN & START
  20. 30    IN2  JOY 2 STATUS & TILT
  21.  
  22. out:
  23. 40    ????
  24. 50    ????  maybe VSYNC ????
  25.  
  26.  ======================================================================
  27.  
  28. Z80 SOUND
  29. 0000-7fff ROM
  30. dc00-dfff shared with MAIN CPU
  31. f000-dfff RAM
  32.  
  33. out:
  34. 00    YM3812 control
  35. 01    YM3812 data
  36. 20    ??
  37.  
  38.  ======================================================================
  39.  
  40.   Colors :   2 bits for foreground characters =  4 colors * 16 palettes
  41.          4 bits for background tiles      = 16 colors * 16 palettes
  42.          4 bits for sprites           = 16 colors * 16 palettes
  43.  
  44. ***************************************************************************/
  45.  
  46. #include "driver.h"
  47. #include "vidhrdw/generic.h"
  48.  
  49.  
  50. unsigned char *speedbal_foreground_videoram;
  51. unsigned char *speedbal_background_videoram;
  52. unsigned char *speedbal_sprites_dataram;
  53.  
  54. size_t speedbal_foreground_videoram_size;
  55. size_t speedbal_background_videoram_size;
  56. size_t speedbal_sprites_dataram_size;
  57.  
  58. int  speedbal_vh_start(void);
  59. void speedbal_vh_stop(void);
  60. void speedbal_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  61. READ_HANDLER( speedbal_foreground_videoram_r );
  62. WRITE_HANDLER( speedbal_foreground_videoram_w );
  63. READ_HANDLER( speedbal_background_videoram_r );
  64. WRITE_HANDLER( speedbal_background_videoram_w );
  65.  
  66.  
  67. unsigned char *speedbal_sharedram;
  68.  
  69. READ_HANDLER( speedbal_sharedram_r )
  70. {
  71. //  if (offset==0x0) speedbal_sharedram[offset]+=1;
  72.   return speedbal_sharedram[offset];
  73. }
  74.  
  75.  
  76. WRITE_HANDLER( speedbal_sharedram_w )
  77. {
  78.     speedbal_sharedram[offset] = data;
  79. }
  80.  
  81. static struct MemoryReadAddress readmem[] =
  82. {
  83.     { 0x0000, 0xdbff, MRA_ROM },
  84.     { 0xdc00, 0xdfff, speedbal_sharedram_r },  // shared with SOUND
  85.     { 0xe000, 0xe1ff, speedbal_background_videoram_r },
  86.     { 0xe800, 0xefff, speedbal_foreground_videoram_r },
  87.     { 0xf000, 0xffff, MRA_RAM },
  88.     { -1 }  /* end of table */
  89. };
  90.  
  91. static struct MemoryWriteAddress writemem[] =
  92. {
  93.     { 0x0000, 0xdbff, MWA_ROM },
  94.     { 0xdc00, 0xdfff, speedbal_sharedram_w, &speedbal_sharedram },  // shared with SOUND
  95.     { 0xe000, 0xe1ff, speedbal_background_videoram_w, &speedbal_background_videoram, &speedbal_background_videoram_size },
  96.     { 0xe800, 0xefff, speedbal_foreground_videoram_w, &speedbal_foreground_videoram, &speedbal_foreground_videoram_size },
  97.     { 0xf000, 0xf5ff, paletteram_RRRRGGGGBBBBxxxx_swap_w, &paletteram },
  98.     { 0xf600, 0xfeff, MWA_RAM },
  99.     { 0xff00, 0xffff, MWA_RAM, &speedbal_sprites_dataram, &speedbal_sprites_dataram_size },
  100.     { -1 }  /* end of table */
  101. };
  102.  
  103. static struct MemoryReadAddress sound_readmem[] =
  104. {
  105.     { 0x0000, 0x7fff, MRA_ROM },
  106.     { 0xdc00, 0xdfff, speedbal_sharedram_r }, // shared with MAIN CPU
  107.     { 0xf000, 0xffff, MRA_RAM },
  108.     { -1 }  /* end of table */
  109. };
  110.  
  111. static struct MemoryWriteAddress sound_writemem[] =
  112. {
  113.     { 0x0000, 0x7fff, MWA_ROM },
  114.     { 0xdc00, 0xdfff, speedbal_sharedram_w }, // shared with MAIN CPU
  115.     { 0xf000, 0xffff, MWA_RAM },
  116.     { -1 }  /* end of table */
  117. };
  118.  
  119. static struct IOReadPort readport[] =
  120. {
  121.     { 0x00, 0x00, input_port_0_r },
  122.     { 0x10, 0x10, input_port_1_r },
  123.     { 0x20, 0x20, input_port_2_r },
  124.     { 0x30, 0x30, input_port_3_r },
  125.     { -1 }  /* end of table */
  126. };
  127.  
  128. static struct IOWritePort writeport[] =
  129. {
  130.     { -1 }  /* end of table */
  131. };
  132.  
  133. static struct IOReadPort sound_readport[] =
  134. {
  135.     { 0x00, 0x00, YM3812_status_port_0_r },
  136.     { -1 }  /* end of table */
  137. };
  138.  
  139. static struct IOWritePort sound_writeport[] =
  140. {
  141.     { 0x00, 0x00, YM3812_control_port_0_w },
  142.     { 0x01, 0x01, YM3812_write_port_0_w },
  143.     { -1 }  /* end of table */
  144. };
  145.  
  146.  
  147.  
  148. INPUT_PORTS_START( speedbal )
  149.     PORT_START      /* DSW2 */
  150.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Bonus_Life ) )
  151.     PORT_DIPSETTING(    0x06, "70000 200000 1M" )
  152.     PORT_DIPSETTING(    0x07, "70000 200000" )
  153.     PORT_DIPSETTING(    0x03, "100000 300000 1M" )
  154.     PORT_DIPSETTING(    0x04, "100000 300000" )
  155.     PORT_DIPSETTING(    0x01, "200000 1M" )
  156.     PORT_DIPSETTING(    0x05, "200000" )
  157. /*    PORT_DIPSETTING(    0x02, "200000" ) */
  158.     PORT_DIPSETTING(    0x00, "None" )
  159.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  160.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  161.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  162.     PORT_DIPNAME( 0x30, 0x30, "Difficulty 1" )
  163.     PORT_DIPSETTING(    0x30, "Very Easy" )
  164.     PORT_DIPSETTING(    0x20, "Easy" )
  165.     PORT_DIPSETTING(    0x10, "Difficult" )
  166.     PORT_DIPSETTING(    0x00, "Very Difficult" )
  167.     PORT_DIPNAME( 0xc0, 0xc0, "Difficulty 2" )
  168.     PORT_DIPSETTING(    0xc0, "Very Easy" )
  169.     PORT_DIPSETTING(    0x80, "Easy" )
  170.     PORT_DIPSETTING(    0x40, "Difficult" )
  171.     PORT_DIPSETTING(    0x00, "Very Difficult" )
  172.  
  173.     PORT_START      /* DSW1 */
  174.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_B ) )
  175.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_2C ) )
  176.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
  177.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_4C ) )
  178.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
  179.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_A ) )
  180.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
  181.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_1C ) )
  182.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  183.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  184.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
  185.     PORT_DIPSETTING(    0x00, "2" )
  186.     PORT_DIPSETTING(    0x30, "3" )
  187.     PORT_DIPSETTING(    0x20, "4" )
  188.     PORT_DIPSETTING(    0x10, "5" )
  189.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
  190.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  191.     PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
  192.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
  193.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  194.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  195.  
  196.     PORT_START
  197.     PORT_BIT( 0x01, IP_ACTIVE_LOW , IPT_BUTTON1 )
  198.     PORT_BIT( 0x02, IP_ACTIVE_LOW , IPT_BUTTON2 )
  199.     PORT_BIT( 0x04, IP_ACTIVE_LOW , IPT_BUTTON4 )
  200.     PORT_BIT( 0x08, IP_ACTIVE_LOW , IPT_BUTTON3 )
  201.     PORT_BIT( 0x10, IP_ACTIVE_LOW , IPT_START2 )
  202.     PORT_BIT( 0x20, IP_ACTIVE_LOW , IPT_START1 )
  203.     PORT_BIT( 0x40, IP_ACTIVE_LOW , IPT_COIN2 )
  204.     PORT_BIT( 0x80, IP_ACTIVE_LOW , IPT_COIN1 )
  205.  
  206.     PORT_START
  207.     PORT_BIT( 0x01, IP_ACTIVE_LOW , IPT_BUTTON1 | IPF_COCKTAIL )
  208.     PORT_BIT( 0x02, IP_ACTIVE_LOW , IPT_BUTTON2 | IPF_COCKTAIL )
  209.     PORT_BIT( 0x04, IP_ACTIVE_LOW , IPT_BUTTON4 | IPF_COCKTAIL )
  210.     PORT_BIT( 0x08, IP_ACTIVE_LOW , IPT_BUTTON3 | IPF_COCKTAIL )
  211.     PORT_BIT( 0x10, IP_ACTIVE_LOW , IPT_TILT    )
  212.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  213.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  214.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  215. INPUT_PORTS_END
  216.  
  217.  
  218.  
  219. static struct GfxLayout charlayout =
  220. {
  221.     8,8,    /* 8*8 characters */
  222.     1024,   /* 1024 characters */
  223.     4,      /* actually 2 bits per pixel - two of the planes are empty */
  224.     { 1024*16*8+4, 1024*16*8+0, 4, 0 },
  225.     { 8+3, 8+2, 8+1, 8+0, 3, 2, 1, 0 },
  226.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },   /* characters are rotated 90 degrees */
  227.     16*8       /* every char takes 16 bytes */
  228. };
  229.  
  230. static struct GfxLayout tilelayout =
  231. {
  232.     16,16,  /* 16*16 tiles */
  233.     1024,   /* 1024 tiles */
  234.     4,      /* 4 bits per pixel */
  235.     { 0, 2, 4, 6 }, /* the bitplanes are packed in one nibble */
  236.     { 0*8+0, 0*8+1, 7*8+0, 7*8+1, 6*8+0, 6*8+1, 5*8+0, 5*8+1,
  237.             4*8+0, 4*8+1, 3*8+0, 3*8+1, 2*8+0, 2*8+1, 1*8+0, 1*8+1 },
  238.     { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
  239.             8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
  240.     128*8  /* every sprite takes 128 consecutive bytes */
  241. };
  242.  
  243. static struct GfxLayout spritelayout =
  244. {
  245.     16,16,  /* 16*16 sprites */
  246.     512,    /* 512 sprites */
  247.     4,      /* 4 bits per pixel */
  248.     { 0, 2, 4, 6 }, /* the bitplanes are packed in one nibble */
  249.     { 7*8+1, 7*8+0, 6*8+1, 6*8+0, 5*8+1, 5*8+0, 4*8+1, 4*8+0,
  250.             3*8+1, 3*8+0, 2*8+1, 2*8+0, 1*8+1, 1*8+0, 0*8+1, 0*8+0 },
  251.     { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
  252.             8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
  253.     128*8  /* every sprite takes 128 consecutive bytes */
  254. };
  255.  
  256. static struct GfxDecodeInfo gfxdecodeinfo[] =
  257. {
  258.     { REGION_GFX1, 0, &charlayout,     256, 16 },
  259.     { REGION_GFX2, 0, &tilelayout,     512, 16 },
  260.     { REGION_GFX3, 0, &spritelayout,   0, 16 },
  261.     { -1 } /* end of array */
  262. };
  263.  
  264.  
  265.  
  266. static struct YM3812interface ym3812_interface =
  267. {
  268.     1,              /* 1 chip (no more supported) */
  269.     3600000,    /* 3.600000 MHz ? (partially supported) */
  270.     { 255 }     /* (not supported) */
  271. };
  272.  
  273.  
  274.  
  275. static struct MachineDriver machine_driver_speedbal =
  276. {
  277.     /* basic machine hardware */
  278.     {
  279.         {
  280.             CPU_Z80,
  281.             4000000,    /* 4 MHz ??? */
  282.             readmem,writemem,readport,writeport,
  283.             interrupt,1
  284.         },
  285.         {
  286.             CPU_Z80,
  287.             2660000,    /* 2.66 MHz ???  Maybe yes */
  288.             sound_readmem,sound_writemem,sound_readport,sound_writeport,
  289.             interrupt,8
  290.         }
  291.     },
  292.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,  /* frames per second, vblank duration */
  293.     1,    /* 1 CPU slices per frame */
  294.     0,
  295.  
  296.     /* video hardware */
  297.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  298.     gfxdecodeinfo,
  299.     768, 768,
  300.     0,
  301.  
  302.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  303.     0,
  304.     speedbal_vh_start,
  305.     speedbal_vh_stop,
  306.     speedbal_vh_screenrefresh,
  307.  
  308.     /* sound hardware */
  309.     0,0,0,0,
  310.     {
  311.         {
  312.             SOUND_YM3812,
  313.             &ym3812_interface
  314.         }
  315.     }
  316. };
  317.  
  318.  
  319.  
  320. /***************************************************************************
  321.  
  322.   Game driver(s)
  323.  
  324. ***************************************************************************/
  325.  
  326. ROM_START( speedbal )
  327.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64K for code: main */
  328.     ROM_LOAD( "sb1.bin",  0x0000,  0x8000, 0x1c242e34 )
  329.     ROM_LOAD( "sb3.bin",  0x8000,  0x8000, 0x7682326a )
  330.  
  331.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64K for second CPU: sound */
  332.     ROM_LOAD( "sb2.bin",  0x0000, 0x8000, 0xe6a6d9b7 )
  333.  
  334.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  335.     ROM_LOAD("sb10.bin",  0x00000, 0x08000, 0x36dea4bf )    /* chars */
  336.  
  337.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  338.     ROM_LOAD( "sb9.bin",  0x00000, 0x08000, 0xb567e85e )    /* bg tiles */
  339.     ROM_LOAD( "sb5.bin",  0x08000, 0x08000, 0xb0eae4ba )
  340.     ROM_LOAD( "sb8.bin",  0x10000, 0x08000, 0xd2bfbdb6 )
  341.     ROM_LOAD( "sb4.bin",  0x18000, 0x08000, 0x1d23a130 )
  342.  
  343.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  344.     ROM_LOAD( "sb6.bin",  0x00000, 0x08000, 0x0e2506eb )    /* sprites */
  345.     ROM_LOAD( "sb7.bin",  0x08000, 0x08000, 0x9f1b33d1 )
  346. ROM_END
  347.  
  348.  
  349. static void init_speedbal(void)
  350. {
  351.     int i;
  352.  
  353.     /* invert the graphics bits on the sprites */
  354.     for (i = 0; i < memory_region_length(REGION_GFX3); i++)
  355.         memory_region(REGION_GFX3)[i] ^= 0xff;
  356. }
  357.  
  358.  
  359.  
  360. GAME( 1987, speedbal, 0, speedbal, speedbal, speedbal, ROT270, "Tecfri", "Speed Ball" )
  361.